﻿--CREATE PROCEDURE [dbo].[ASMS_SP_GetRealtimeDialySettlement]
--	@businessId uniqueidentifier,
--	@stationId uniqueidentifier,
--	@beginTime datetime,
--	@endTime datetime
--AS
--SELECT 
--	(SELECT SUM(CCR1.Amount) FROM ASMS_CapitalChangedRecord AS CCR1 WHERE CCR1.BusinessId= @businessId and CCR1.StationId = @stationId and CCR1.CreatedTime >= @beginTime and CCR1.CreatedTime <= @endTime) as GeneralIncome,
--	(SELECT COUNT(C1.Id) FROM ASMS_Customer as C1 where C1.[Status] = 1) as CustomerCount,
--	(SELECT COUNT(C2.Id) FROM ASMS_Customer as C2 where C2.[Status] = 1 and C2.CreatedTime >= @beginTime and C2.CreatedTime <= @endTime) as CustomerIncrease,
--	(SELECT COUNT(M1.Id) from ASMS_MaintenanceBill as M1 where M1.BusinessId = @businessId and M1.StationId = @stationId and M1.CreatedTime >= @beginTime and M1.CreatedTime <= @endTime) as MaintenanceBillCount,
--	(SELECT SUM(S1.CreditAmount) from ASMS_SettlementBill as S1 where S1.BusinessId = @businessId and S1.StationId = @stationId and S1.CreatedTime >= @beginTime and S1.CreatedTime <= @endTime) as MaintenanceBillCreditAmount,
--	(SELECT SUM(S1.PaidAmount) from ASMS_SettlementBill as S1 where S1.BusinessId = @businessId and S1.StationId = @stationId and S1.CreatedTime >= @beginTime and S1.CreatedTime <= @endTime) as MaintenanceBillPaidAmount,
--	0 as MaintenanceBillGrossProfit,
--	(select Count(SBSI.Id) from ASMS_SettlementBillServiceItem as SBSI inner join ASMS_SettlementBill as S1 on S1.[Status] = 1 and S1.BusinessId = @businessId and S1.StationId = @stationId and S1.CreatedTime >= @beginTime and S1.CreatedTime <= @endTime) as ServiceItemCount,
--	(select Sum(SBSI.Amount) from ASMS_SettlementBillServiceItem as SBSI inner join ASMS_SettlementBill as S1 on S1.[Status] = 1 and S1.BusinessId = @businessId and S1.StationId = @stationId and S1.CreatedTime >= @beginTime and S1.CreatedTime <= @endTime) as ServiceItemAmount,
--	0 as ServiceItemDiscount,
--	0 as ServiceItemPackage,
--	0 as ServiceItemCommission,


--RETURN 0
